﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Wix.Aura.Common;
using Wix.Aura.Common.CustomTypes;

namespace Wix.Aura.UnitTests.Common {
	[TestFixture]
	public class ComponentClassSerialization : ComponentChildren {

		[Test]
		public void DefaultCategory() {
			Guid id = Guid.NewGuid();
			Class c = new Class(id);
			component.Class.Add(c);

			string expected = string.Format(baseXml, string.Format(@"<Class Id=""{0}"" />", id.ToString().ToUpper()));

			Assertion(expected, project);
		}

		[Test]
		public void AllAttributes() {
			Guid id = Guid.NewGuid();
			Class c = new Class(id);
			c.Advertise = YesNoType.Yes;
			c.AppId = Guid.Empty;
			c.Argument = "Argument";
			c.Context = Context.InprocServer;
			c.Context |= Context.InprocServer32;
			c.Control = YesNoType.Yes;
			c.Description = "Description";
			c.ForeignServer = "ForeignServer";
			c.Handler = "Handler";
			c.Icon = "Icon";
			c.IconIndex = 2;
			c.Insertable = YesNoType.Yes;
			c.Programmable = YesNoType.Yes;
			c.RelativePath = YesNoType.Yes;
			c.SafeForInitializing = YesNoType.Yes;
			c.SafeForScripting = YesNoType.Yes;
			c.Server = "Server";
			c.ShortPath = YesNoType.Yes;
			c.ThreadingModel = ThreadingModel.Free;
			c.Version = "0.0.0.0";
			component.Class.Add(c);

			string expected = string.Format(baseXml, string.Format(@"<Class Id=""{0}"" Advertise=""yes"" AppId=""00000000-0000-0000-0000-000000000000"" Argument=""Argument"" Context=""InprocServer InprocServer32"" Control=""yes"" Description=""Description"" ForeignServer=""ForeignServer"" Handler=""Handler"" Icon=""Icon"" IconIndex=""2"" Insertable=""yes"" Programmable=""yes"" RelativePath=""yes"" SafeForInitializing=""yes"" SafeForScripting=""yes"" Server=""Server"" ShortPath=""yes"" ThreadingModel=""Free"" Version=""0.0.0.0"" />", id.ToString().ToUpper()));

			Assertion(expected, project);
		}
	}
}
